<template>
  <div class="page-view">
    <van-field
      v-model="Content"
      clearable
      :placeholder="Text[Type - 1]"
      :maxlength="inputMaxLength"
      class="form"
    />
    <div class="btn-div">
      <van-button
        type="primary"
        class="btn"
        @click="onSubmit"
      >
        确定
      </van-button>
    </div>
  </div>
</template>
<script lang="ts">
import Vue from 'vue'
export default Vue.extend({
  data () {
    return {
      Type: this.$route.query.type,
      Content: this.$route.query.content,
      Text: ['请输入您的工作单位', '请输入您的通信地址', '请输入您的毕业院校', '请输入您的毕业证书编号', '请输入您的居住地'],
      inputMaxLength: this.$route.query.type === '5' ? 200 : '',
    }
  },
  methods: {
    isValidateContent () {
      if (this.Content === '') {
        this.$toast({ message: this.Text[+this.Type - 1], duration: 1000 })
        return false
      } else {
        return true
      }
    },
    // 提交
    onSubmit () {
      if (this.isValidateContent()) {
        console.log('Content', this.Content, this.Type)
        this.$axios({
          url: 'Setting/UpdateMyIndexMoreInfoForH5',
          data: {
            Type: this.Type === '5' ? '14' : this.Type, // 居住地Type=14
            Content: this.Content,
          },
        }).then(res => {
          this.$router.back()
          setTimeout(() => {
            this.$toast({ message: '更新成功！', duration: 1000 })
          }, 100)
        })
      }
    },
  },
})
</script>
<style lang="scss" scoped>
@import "~scss/mine/changeInfo.scss";
</style>
